package com.abc.live.widget.common;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import me.jessyan.autosize.internal.CancelAdapt;

/**
 * Created by qyqx on 2018/9/4.
 */

public class AppSettingsDialogHolderNewActivity extends AppCompatActivity implements DialogInterface.OnClickListener,CancelAdapt {

    public static Intent createShowDialogIntent(Context context, AppSettingsNewDialog dialog) {
        return new Intent(context, AppSettingsDialogHolderNewActivity.class)
                .putExtra(AppSettingsNewDialog.EXTRA_APP_SETTINGS, dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppSettingsNewDialog dialog = getIntent().getParcelableExtra(AppSettingsNewDialog.EXTRA_APP_SETTINGS);
        dialog.setContext(this);
        dialog.setActivityOrFragment(this);
        dialog.setNegativeListener(this);
        dialog.showDialog();
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        setResult(Activity.RESULT_CANCELED);
        finish();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        setResult(resultCode, data);
        finish();
    }
}
